import Qt 4.7
import Qt.labs.folderlistmodel 1.0

Rectangle {
    id: window
    width: 640; height: 480
    color: "black"
    FolderListModel {
        id: webshotFolderModel
        folder: "\\temp\\"
        nameFilters: ["*.thumb.png"]
        showDirs : false
    }

    Component {
        id: webshotDelegate
        Column {
            id: webshot
            spacing: 20
                Image {
                    id: webshotImage
                    source: "\\temp\\"+fileName
                    width: 100

                    fillMode: Image.PreserveAspectFit
                    MouseArea {
                        anchors.fill:  webshotImage
                        onDoubleClicked: {
                            webshotFull.visible = true;
                            webshotFullImage.source = "\\temp\\"+fileName.replace(".thumb.png",".png");
                        }
                    }
                }
                Item {
                    id: mirror

                    Image {
                        id: image
                        source: "\\temp\\"+fileName
                        width: 100
                        fillMode: Image.PreserveAspectFit
                    }
                    Rectangle {
                          width: image.width; height: image.height
                          gradient: Gradient {
                             GradientStop { position: 0.1; color: "black" }
                             GradientStop { position: 1.0; color: Qt.rgba(0,0,0,0.8) }
                          }
                    }
                    transform: [
                        Translate { y: -image.height*2 },
                        Rotation {
                            origin.x:  mirror.width/2
                            origin.y:  mirror.height/2
                            axis { x: 1; y: 0; z: 0 }
                            angle: 180
                        }
                    ]
                }

        }
    }

        PathView {
            id: webshotBrowser
            anchors.fill:  parent
            model: webshotFolderModel
            pathItemCount: 5

            focus: true
            delegate: webshotDelegate
            path: Path {
                startX: 0
                startY: webshotBrowser.height/2
                PathLine { x: webshotBrowser.width; y: webshotBrowser.height/2 }
            }

            Keys.onLeftPressed: decrementCurrentIndex()
            Keys.onRightPressed: incrementCurrentIndex()
        }

        Rectangle {
            id: webshotFull
            visible: false
            color: "black"
            anchors.fill: parent

            Column {
                Rectangle {
                    id: menu
                    color: "black"
                    height: 30
                    width: window.width
                    gradient: Gradient {
                       GradientStop { position: 0.1; color: "darkgray" }
                       GradientStop { position: 1.0; color: "gray" }
                    }
                    Text {
                        anchors.horizontalCenter: parent.horizontalCenter
                        anchors.verticalCenter: parent.verticalCenter
                        text: "Close"
                    }

                    MouseArea {
                        anchors.fill: parent
                        onClicked: {
                            webshotFull.visible = false
                            webshotFullImage.source = ""
                        }
                    }

                }

                Image {
                    id: webshotFullImage
                    fillMode: Image.PreserveAspectFit

                }

            }
        }
}
